package mbcontrol;

import java.sql.Connection;
import java.sql.ResultSet;

import uteis.Constantes;

public class MBSelectFormaPagto {

	Connection conexao;

	public String LocalizaFormaPagto(String nmformapagto) {

		String result = "";
		if (!nmformapagto.trim().equals("")) {

			String sql = "SELECT NMFORMAPAGTO FROM FORMAPAGTO WHERE (NMFORMAPAGTO like '"
					+ nmformapagto
					+ "' and CDEMPRESA = "
					+ Constantes.cdempresas + ") ORDER BY NMFORMAPAGTO ASC;";
			String scdformapagto = "";
			try {
				java.sql.Statement stmt = conexao.createStatement();
				ResultSet valuesformapagto = stmt.executeQuery(sql);

				valuesformapagto.first();
				scdformapagto = valuesformapagto.getString("NMFORMAPAGTO");
				// result.add(scdregistro);
				result = (scdformapagto);
				System.out.println("FORMA PAGTO " + scdformapagto
						+ " ------------- " + result);

			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			System.out.println("VALOR EM BRANCO " + nmformapagto
					+ " ------------- " + result);
		}
		return result;
	}
}
